<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <%@include file="/common/common.jspf" %>

    <link rel="stylesheet" href="${ctx}/js/date/bootstrap_select.min.css">
    <script src="${ctx}/js/date/bootstrap_select.min.js"></script>

    <script type="text/javascript" src="${ctx}/js/system/user/edit.js">
    </script>
    <style type="text/css">
        .col-sm-3 {
            width: 15%;
            float: left;
        }

        .col-sm-9 {
            width: 35%;
            float: left;
        }
        label[class^="btn btn-default"]{
            margin-top: -4px;
        }
    </style>
</head>
<body>
<div class="l_err" style="width: 100%; margin-top: 2px;"></div>
<form id="form" name="form" class="form-horizontal" method="post"
      action="${ctx}/devicemaintain/maintain_editEntity.shtml">
    <input type="hidden" value="${user.deviceMaintainId}" name="deviceMaintainFormMap.deviceMaintainId">
    <section class="panel panel-default">
        <div class="panel-body">
            <div class="form-group">
                <label class="col-sm-3 control-label">设备维修编号</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control " name="deviceMaintainFormMap.devicemaintaincode" id="devicemaintaincode" value="${user.devicemaintaincode}" readonly = readonly >
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">设备名称</label>
                    <div class="col-sm-9">
                        <select data-live-search="true" class="form-control selectpicker show-tick" name="deviceMaintainFormMap.deviceFaultId" id="deviceFaultId" >
                            <c:forEach items="${device}" var="device">
                                <c:choose>
                                    <c:when test="${device.deviceCode == user.deviceFaultId}">
                                        <option value="${device.deviceCode}" selected = "selected">${device.deviceName}</option>
                                    </c:when>
                                    <c:otherwise>
                                        <option value="${device.deviceCode}">${device.deviceName}</option>
                                    </c:otherwise>
                                </c:choose>
                            </c:forEach>
                        </select>

                        <%--<select class="form-control" name="deviceMaintainFormMap.deviceFaultId" id="deviceFaultId">--%>
                            <%--<c:forEach items="${devType}" var="type">--%>
                                <%--<c:choose>--%>
                                    <%--<c:when test="${type.deviceTypeId == user.deviceFaultId}">--%>
                                        <%--<option value="${type.deviceTypeId}" selected = "selected">${type.deviceTypeName}</option>--%>
                                    <%--</c:when>--%>
                                    <%--<c:otherwise>--%>
                                        <%--<option value="${type.deviceTypeId}">${type.deviceTypeName}</option>--%>
                                    <%--</c:otherwise>--%>
                                <%--</c:choose>--%>
                            <%--</c:forEach>--%>
                        <%--</select>--%>

                    </div>
                </div>
            </div>
            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <label class="col-sm-3 control-label" disabled="disabled">设备位置</label>
                <div class="col-sm-9">
                    <input type="text" class="form-control checkName" value="${user.deviceMaintainLocation}" name="deviceMaintainFormMap.deviceMaintainLocation" id="deviceMaintainLocation">
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">设备型号</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control" readonly = readonly
                               name="deviceMaintainFormMap.deviceMaintainType" id="deviceMaintainType" value="${user.deviceMaintainType}">
                    </div>
                </div>
            </div>

            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <label class="col-sm-3 control-label">报修人</label>
                <div class="col-sm-9">
                    <%--<input type="text" class="form-control"--%>
                    <%--name="deviceMaintainFormMap.deviceMaintainEmp" id="deviceMaintainEmp">--%>
                    <select class="form-control selectpicker show-tick" data-live-search="true" name="deviceMaintainFormMap.deviceMaintainEmp" id="deviceMaintainEmp" >
                        <c:forEach items="${emp}" var="emps">
                            <c:choose>
                                <c:when test="${emps.empI == user.deviceMaintainEmp}">
                                    <option value="${emps.empI}" selected = "selected">${emps.empName}</option>
                                </c:when>
                                <c:otherwise>
                                    <option value="${emps.empI}">${emps.empName}</option>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>

                    </select>


                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">备注</label>
                    <div class="col-sm-9">
                        <input type="text" class="form-control "
                                name="deviceMaintainFormMap.note" id="note" value="${user.note}">
                    </div>
                </div>
            </div>
            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <label class="col-sm-3 control-label">故障现象</label>
                <div class="col-sm-9">
                    <textarea name="deviceMaintainFormMap.deviceMaintainCause" id="deviceMaintainCause" style="width: 628px; height: 130px;" >${user.deviceMaintainCause}</textarea>
                </div>
            </div>

        </div>
        <footer class="panel-footer text-right bg-light lter">
            <button type="submit" class="btn btn-success btn-s-xs">提交</button>
        </footer>
    </section>
</form>
<script type="text/javascript">

    $(document).ready(function(){
        $('select').selectpicker();
    });

    $("#deviceFaultId").change(function(e){
        var options = $("#deviceFaultId option:selected");//获取选中数据
        console.log("change..")
        $.ajax({
            url: rootPath + "/devicemaintain/getType.shtml",
            data: {id: options.val()},
            type: "GET",
            dataType: "json",
            success: function(data) {
                d = data.replace("\"","").replace("\"","");
                $("#deviceMaintainType").val(d)
            }
        });

    })


</script>
</body>
</html>